/***************************************************************************
 * Open Object Oriented ANSI C                                             *
 ***************************************************************************
 * Code given under the terms of GNU General Public Licence (GPLv3)        *
 * and without any waranties of any kind including but not limitative to   *
 * waranties on merchandability or any particular applications fitness.    *
 * For more information on GNU/GPL go on :                                 *
 * "http://www.gnu.org/copyleft/gpl.html"                                  *
 *                                                                         *
 * You are allowed to use it for any purposes in the terms of GNU/GPLv3    *
 * (or more).                                                              *
 * This text MUST stay in state on copyed sources (or sources using it)    *
 * and must not be altered.                                                *
 * You are allowed to add your name at the end of the Copylefs list.       *
 ***************************************************************************
 * Copylefts List :                                                        *
 ***************************************************************************
 * 2010-03-20 Patrick PIGNOL <pignol_patrick@hotmail.com> (Original)       *
 * (Type your name here if needed)                                         *
 ***************************************************************************/
#ifndef STACK_H_INCLUDED
#define STACK_H_INCLUDED

#define STACK_TYPEID 1

#include "Class.h"

/* Sealed */
typedef struct StackVirtualTable StackVirtualTable;
typedef struct Stack Stack;

struct StackVirtualTable
{
    unsigned long int TypeID;
    ClassInterface* Interface;
    ClassVirtualTable* AncestorTable;
    unsigned long int ReferenceCount;
    Stack* (*new)(unsigned long int pArgsCount, va_list* pParameters);
    StackVirtualTable* (*Initialize)(Stack* this, unsigned long int pArgsCount, va_list* pParameters);
    void (*Garbage)(Stack* this);
    unsigned long int (*TypeOf)(Stack* this);
    bool (*IsSameTypeThanTypeID)(Stack* this, unsigned long int pTypeID);
    bool (*IsKindOfTypeID)(Stack* this, unsigned long int pTypeID);
    bool (*IsSameTypeThan)(Stack* this, Class* pSource);
    bool (*IsKindOf)(Stack* this, Class* pSource);
};

/*LIFO Agregator Class*/
struct Stack
{
    StackVirtualTable* VirtualTable;
    void (*Constructor)(Stack* this, unsigned long int pArgsCount, va_list* pParameters); /* Constructor pointer of object. Called by Initialise(). */
    void (*Destructor)(Stack* this); /* Destructor pointer of object. Called by Garbage(). */
    Stack* (*Clone)(Stack* this);
    Class** aStack;/*MUST NOT BE ACCESSED, INTERNAL USE ONLY !!!! Think it as like private !*/
    unsigned long int aCount;/*MUST NOT BE ACCESSED, INTERNAL USE ONLY !!!! Think it as like private !*/
    void (*Push)(Stack* this, Class* pObject);
    Class* (*Pop)(Stack* this);
    unsigned long int (*Count)(Stack* this);
};

Stack* StackNew(unsigned long int pArgsCount, va_list* pParameters);
StackVirtualTable* StackInitialize(Stack* this, unsigned long int pArgsCount, va_list* pParameters); /* return this (!= 0 on success, 0 on error).*/
void StackConstructor(Stack* this, unsigned long int pArgsCount, va_list* pParameters);
void StackDestructor(Stack* this);
Stack* StackClone(Stack* this);
void StackPush(Stack* this, Class* pObject);
Class* StackPop(Stack* this);
unsigned long int StackCount(Stack* this);

#endif /* STACK_H_INCLUDED*/
